package org.fb.boot;

import org.fb.client.RpcConsumer;
import org.fb.dto.RpcRequest;
import org.fb.dto.RpcResponse;
import org.fb.service.IUserService;

import java.util.UUID;

/**
 * @author fanbo@imoran.net
 * @date 2021/2/6 21:40
 */
public class ConsumerBoot {

    /**
     * 参数定义
     */
    private static final String PROVIDER_NAME = "UserService#sayHello#";

    public static void main(String[] args) throws InterruptedException {
        //1.创建代理对象
        IUserService userService = (IUserService) RpcConsumer.createProxy(IUserService.class, PROVIDER_NAME);

        //2.循环给服务器写数据
        int cnt = 0;
        while (true) {
            cnt++;
            System.out.println("第" + cnt + " 客户端请求...");
            RpcResponse result = userService.sayHello("Are you ok, Jack?");
            System.out.println("服务端返回结果：" + result.toString());
            System.out.println("第" + cnt + " 客户端请求结束");

            //睡2s方便查看输出
            Thread.sleep(2000);
        }
    }
}

